package com.dantwining.gwitbus;

import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JSplitPane;

import com.google.gwt.event.shared.HandlerManager;

@SuppressWarnings("serial")
public class GwitBusExample extends JFrame {

	private HandlerManager gwitBus = new HandlerManager(this);

	public GwitBusExample() {
		super("GwitBus Example");

		setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

		JMenu menu1 = new JMenu("File");
		JMenuItem open = new JMenuItem("Open");
		open.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				gwitBus.fireEvent(new OpenEvent());
			}
		});
		menu1.add(open);

		JMenuBar bar = new JMenuBar();
		bar.add(menu1);

		setJMenuBar(bar);

		JPanel leftSide = new JPanel();
		JPanel rightSide = new JPanel();

		JSplitPane splitPane = new JSplitPane();
		splitPane.setLeftComponent(leftSide);
		splitPane.setRightComponent(rightSide);
		splitPane.setDividerLocation(400);

		add(splitPane, BorderLayout.CENTER);

		pack();
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		java.awt.EventQueue.invokeLater(new Runnable() {
			public void run() {
				GwitBusExample gwitBusExample = new GwitBusExample();
				gwitBusExample.setSize(800, 600);
				gwitBusExample.setVisible(true);
			}
		});
	}

}
